package com.caozhi.mspeoject.nb_search.controller;

import com.caozhi.mspeoject.nb_search.repository.MessageSearchRepository;
import com.woniuxy.boot.common.bean.EsMessage;
import com.woniuxy.boot.common.dto.EsMessageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("messageSearch")
public class MessageController {
@Autowired
    private MessageSearchRepository messageSearchRepository;
@PostMapping("get")
    public List<EsMessage> getMessages(@RequestBody EsMessageDTO esMessageDTO) {
    System.out.println(esMessageDTO);
    if(esMessageDTO.getKeyword() == null ){
        return messageSearchRepository.findByTitleOrNoOrId(null , null , null);
    }
    return messageSearchRepository.findByTitleOrNoOrId(esMessageDTO.getKeyword() , esMessageDTO.getKeyword() , esMessageDTO.getId());
}
}
